home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / AppleScript / QUICKTIME 5.0.2 SCRIPTS / Example Files / Favorites Examples / Add Movies In Folder.txt < prev   
Encoding:
Text File  |  2001-06-04  |  2.5 KB  |  66 lines

  1. property type_list : {"MooV", "MPEG"}
  2. property extension_list : {".mov", ".mpg"}
  3.  
  4.  
  5. tell application "QuickTime Player"
  6.     launch
  7.     activate
  8.     try
  9.         --if not (exists movie 1) then error "No movies are open."
  10.         stop every movie
  11.         -- CHECK FOR THE CORRECT VERSION
  12.         set QT_version to (QuickTime version as string)
  13.         set player_version to (version as string)
  14.         if (QT_version is less than "5.0") or ¬
  15.             (player_version is less than "5.0") then
  16.             error "This script requires QuickTime 5.0 or greater." & ¬
  17.                 return & return & ¬
  18.                 "Current QuickTime Version: " & QT_version & return & ¬
  19.                 "Current QuickTime Player Version: " & player_version
  20.         end if
  21.         -- CHECK FOR QUICKTIME PRO
  22.         if QuickTime Pro installed is false then
  23.             set the target_URL to "http://www.apple.com/quicktime/download/"
  24.             set the message_text to "This script requires QuickTime Pro." & return & return & ¬
  25.                 "If this computer is currently connected to the Internet, " & ¬
  26.                 "click the “Upgrade” button to visit the QuickTime Website at:" & ¬
  27.                 return & return & target_URL
  28.             display dialog message_text buttons {"Upgrade", "Cancel"} default button 2
  29.             ignoring application responses
  30.                 tell application "Finder"
  31.                     open location target_URL
  32.                 end tell
  33.             end ignoring
  34.             error number -128
  35.         end if
  36.         set this_folder to choose folder with prompt "Choose a folder containing the movies:"
  37.         set the folder_items to list folder this_folder without invisibles
  38.         set the folder_path to this_folder as string
  39.         repeat with i from 1 to the count of the folder_items
  40.             set this_item to (item i of the folder_items)
  41.             set this_item to (this_folder & this_item) as string
  42.             set the item_info to info for alias this_item
  43.             if ((folder of the item_info is false) and ¬
  44.                 (alias of the item_info is false)) and ¬
  45.                 (the file type of the item_info is in the type_list) or ¬
  46.                 (my check_extension(the name of the item_info) is true) then
  47.                 try
  48.                     make favorite with data alias this_item
  49.                 end try
  50.             end if
  51.         end repeat
  52.         display dialog "The items have been added to the favorites." buttons {"•"} default button 1 giving up after 2
  53.     on error error_message number error_number
  54.         if the error_number is not -128 then
  55.             beep
  56.             display dialog error_message buttons {"Cancel"} default button 1
  57.         end if
  58.     end try
  59. end tell
  60.  
  61. on check_extension(this_filename)
  62.     repeat with i from 1 to the count of the extension_list
  63.         if this_filename ends with (item i of the extension_list) then return true
  64.     end repeat
  65.     return false
  66. end check_extension